import http from '@/plugins/aixos'
import { towerModel } from '@/types/model'

export const findAllTower = (args = {}) => {
  const url =
    '/tower?' +
    Object.entries(args)
      .map(([key, value]) => `${key}=${value}`)
      .join('&')
  return http.request<towerModel[]>({
    url,
    method: 'GET',
  })
}

export const addTower = (data: towerModel) => {
  return http.request<towerModel>({
    url: '/tower/',
    data,
    method: 'POST',
  })
}

export const delTowers = async (id: number) => {
  return await http.request({
    url: `/tower/towers/${id}`,
    method: 'DELETE',
  })
}

export const findTowerById = (id: number) => {
  return http.request<towerModel>({
    url: `/tower/${id}`,
    method: 'GET',
  })
}
